<template>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="sidebar" data-tagger="topSideBar">
                    <i class="fa fa-list-ul"></i>
                </button>
                <a class="navbar-brand" href="#">Brand</a>
            </div>

            <div class="sidebar navbar-sidebar" id="topSideBar">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
                    <li><a href="#">Link</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span
                            class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Action</a></li>
                            <li><a href="#">Another action</a></li>
                            <li><a href="#">Something else here</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Separated link</a></li>
                            <li class="divider"></li>
                            <li><a href="#">One more separated link</a></li>
                        </ul>
                    </li>
                </ul>
                <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search">
                    </div>
                    <button type="submit" class="btn btn-default">Submit</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Link</a></li>
                </ul>
            </div>
        </div>
    </nav>
</template>

<script>
    /* eslint-disable no-undef */
    export default {
    	name: 'NavBar',
        mounted () {
            $('[data-toggle="sidebar"]').click(function () {
                let id = $(this).attr('data-tagger');
                let ul = $('#' + id);
                if (ul.length <= 0) return;
                let a = 'data-sidebar-show';
                let open = ul.attr(a);
                if (open === undefined || open === 'false') {
                    ul.animate({'left': 0}, 500);
                    ul.attr(a, true);
                } else {
                    ul.animate({'left': '-80%'}, 500);
                    ul.attr(a, false);
                }
            });
        }
    };
</script>

<style lang="scss">
    @import "../../sass/custom/_navbar.scss";
</style>
